<template>
    <view>
        <web-view v-if="url" :src="url"></web-view>
    </view>
</template>

<script setup name="BaseWebView">
/**
 * @name  网络链接内容展示页（uni-id-pages中用于展示隐私政策协议内容|嵌套H5页面内容）
 */
import { ref, onMounted } from 'vue'

// * 传参参数
const props = defineProps({
    url: {
        type: String,
        require: true,
    },
    title: {
        type: String,
        require: true,
    }
})

const url = ref(null)
const title = ref(props.title)
onMounted(() => {
    if (props.url.substring(0, 4) != 'http') {
        uni.showModal({
            title: "错误",
            content: '不是一个有效的网站链接,' + '"' + props.url + '"',
            showCancel: false,
            confirmText: "知道了",
            complete: () => {
                uni.navigateBack()
            }
        });
        title.value = "页面路径错误"
    } else {
        url.value = props.url;
    }
    if (title.value) {
        // * 动态设置标题
        uni.setNavigationBarTitle({ title: title.value });
    }
})

</script>

<style lang="scss" scoped></style>
